package com.tripwego.client.ui.widget;

import com.google.gwt.event.shared.EventBus;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.DisclosurePanel;
import com.tripwego.client.model.DayModel;
import com.tripwego.client.ui.pageVoyage.IVoyageView;

public class DayWidget extends Composite implements IVoyageView {

	private Presenter presenter;

	private EventBus eventBus;

	private DayModel dayModel;

	/*
	 * Elements graphiques
	 */
	private DisclosurePanel viewPanel = new DisclosurePanel();

	private DayHeaderWidget header;
	
	private DayContentWidget content;

	/**
	 * 
	 */
	public DayWidget() {
		super();

		// viewPanel.setStyleName("DayWidget");

		header = new DayHeaderWidget();
		content = new DayContentWidget(this);

		viewPanel.removeStyleDependentName("gwt-DisclosurePanel");
		viewPanel.removeStyleName("gwt-DisclosurePanel");
		viewPanel.setOpen(false);
		viewPanel.setAnimationEnabled(true);

		viewPanel.setHeader(header);
		header.setSize("350px", "1%");
		
		viewPanel.setContent(content);
		content.setSize("100%", "100%");		
		
		viewPanel.setContent(content);
		content.setSize("100%", "100%");

		initWidget(viewPanel);
	}

	@Override
	public void setPresenter(Presenter presenter) {
		this.presenter = presenter;
	}

	@Override
	public void setEventBus(EventBus eventBus) {
		this.eventBus = eventBus;
	}

	@Override
	public void init() {
		header.setPresenter(presenter);
		header.setEventBus(eventBus);
		header.setDayModel(dayModel);
		header.init();

		content.setPresenter(presenter);
		content.setEventBus(eventBus);
		content.setDayModel(dayModel);
		content.init();
	}

	/**
	 * @return the content
	 */
	public DayContentWidget getContent() {
		return content;
	}

	/**
	 * @param content
	 *            the content to set
	 */
	public void setContent(DayContentWidget content) {
		this.content = content;
	}

	public void open(boolean open) {
		viewPanel.setOpen(open);
	}

	/**
	 * @return the dayModel
	 */
	public DayModel getDayModel() {
		return dayModel;
	}

	/**
	 * @param dayModel
	 *            the dayModel to set
	 */
	public void setDayModel(DayModel dayModel) {
		this.dayModel = dayModel;
	}

}
